/*
 *  ThreadLocals.c
 *  Platform
 *
 *  Created by Sven Weidauer on 12.04.10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#include <Platform/ThreadLocals.h>

#include <windows.h>

bool MPCreateThreadLocalVar( MPThreadLocalVar *outVar )
{
    if (!outVar) return false;
    
    DWORD slot = TlsAlloc();
    if (TLS_OUT_OF_INDEXES == slot) return false;
    
    *outVar = (MPThreadLocalVar)slot;
    return true;
}

void *MPGetThreadLocalVar( MPThreadLocalVar var )
{
    return TlsGetValue( (DWORD)var );
}

bool MPSetThreadLocalVar( MPThreadLocalVar var, void *value )
{
    return TlsSetValue( (DWORD)var, value );
}

